/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.example;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * <p>Project: javaseapp - Date01
 * <p>Powered by webrx On 2021-07-28 11:50:27
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Date03 {
    public static void main(String[] args) throws ParseException {
        Locale.setDefault(Locale.US);
        Calendar c = Calendar.getInstance();

        c.set(2021, 7 - 1, 27);
        //year
        int year = c.get(1);
        System.out.println(year);

        int month = c.get(Calendar.MONTH) + 1;
        System.out.println(month);

        int day = c.get(Calendar.DAY_OF_MONTH);
        System.out.println(day);

        int hh = c.get(Calendar.HOUR);//12小时
        hh = c.get(Calendar.HOUR_OF_DAY);//24小时
        System.out.println(hh);

        int mm = c.get(Calendar.MINUTE);
        System.out.println(mm);
        int ss = c.get(Calendar.SECOND);
        System.out.println(ss);
        int wk = c.get(Calendar.DAY_OF_WEEK);
        //1 星期日 2 星期一  3星期二 4 星期三 5 星期四 6星期五 7星期六
        //System.out.println(wk);
        if (wk == 1) {
            System.out.println("今日是星期日");
        } else if (wk == 2) {
            System.out.println("今日是星期一");
        } else if (wk == 3) {
            System.out.println("今日是星期二");
        } else if (wk == 4) {
            System.out.println("今日是星期三");
        } else if (wk == 5) {
            System.out.println("今日是星期四");
        } else if (wk == 6) {
            System.out.println("今日是星期五");
        } else {
            System.out.println("今日是星期六");
        }


        Locale.setDefault(Locale.CHINA);
        System.out.printf("%tA%n",c);

        Date d = new Date();
        //0 星期日 1 星期一 6 星期六
        int ww = d.getDay();
        System.out.println(ww);
    }
}
